Skip to content

feat: enhance ALTER TABLE support with UNIQUE KEY and INVISIBLE index - #2234

Merged
manticore-projects merged 3 commits into
JSQLParser:masterfrom
minleejae:feat/index
Apr 30, 2025
Merged

feat: enhance ALTER TABLE support with UNIQUE KEY and INVISIBLE index#2234
manticore-projects merged 3 commits into
JSQLParser:masterfrom
minleejae:feat/index

Conversation

@minleejae

Copy link
Copy Markdown
Contributor

Description

This PR adds support for two MySQL DDL statements:

ALTER TABLE ADD CONSTRAINT UNIQUE KEY syntax
ALTER TABLE ALTER INDEX INVISIBLE syntax

Problem Solved

Previously, JSqlParser couldn't properly parse the following SQL statements:

ALTER TABLE sbtest1 ADD CONSTRAINT UNIQUE KEY ux_c3 (c3);
ALTER TABLE sbtest1 ALTER INDEX c4 INVISIBLE;

These are valid MySQL syntax for adding a unique constraint with a custom name and for making an index invisible to the query optimizer while keeping it maintained.

Related Issue

#2076

@minleejae

Copy link
Copy Markdown
Contributor Author

Hi, @manticore-projects

Could you please let me know when the JSqlParser 5.2 release is scheduled?
I'd like to reference this for planning purposes in my project.

Thanks!

@manticore-projects

Copy link
Copy Markdown
Contributor

Could you please let me know when the JSqlParser 5.2 release is scheduled?

Unfortunately this is not on me, but I will ask @wumpz immediately and with some luck, he will get this done in May.
Would this work for you?

@manticore-projects

Copy link
Copy Markdown
Contributor

Please fix formatting exceptions.

@minleejae

Copy link
Copy Markdown
Contributor Author

@manticore-projects
Thanks for the reply!

I'm currently working on a project that depends on JSqlParser, and I'm considering switching to the official release version rather than using a custom build.
There's no urgency at all — I just wanted to get a rough idea of the possible timeline.
Appreciate your help, thank you!

@manticore-projects

Copy link
Copy Markdown
Contributor

Thank you for your work and effort! Cheers!

@manticore-projects
manticore-projects merged commit 78318bb into JSQLParser:master Apr 30, 2025
aparajon added a commit to aparajon/JSqlParser that referenced this pull request Aug 5, 2026
…ABLE and CREATE INDEX

MySQL 8.0 invisible indexes (KEY idx (col) INVISIBLE) and invisible columns
failed to parse inside CREATE TABLE, and CREATE INDEX ... INVISIBLE failed
too, because CreateParameter() did not accept the K_VISIBLE/K_INVISIBLE
tokens. The ALTER TABLE productions already support them (JSQLParser#2076 was fixed
for ALTER TABLE only, via JSQLParser#2234); this covers the CREATE statements, which
share CreateParameter(). Tests cover index and column visibility, mixing
visibility with other index options in either order, and quoted columns
named visible/invisible.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
manticore-projects pushed a commit that referenced this pull request Aug 7, 2026
…ABLE and CREATE INDEX (#2449)

MySQL 8.0 invisible indexes (KEY idx (col) INVISIBLE) and invisible columns
failed to parse inside CREATE TABLE, and CREATE INDEX ... INVISIBLE failed
too, because CreateParameter() did not accept the K_VISIBLE/K_INVISIBLE
tokens. The ALTER TABLE productions already support them (#2076 was fixed
for ALTER TABLE only, via #2234); this covers the CREATE statements, which
share CreateParameter(). Tests cover index and column visibility, mixing
visibility with other index options in either order, and quoted columns
named visible/invisible.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants